package chapter06

object Test07_Inherit {
  def main(args: Array[String]): Unit = {

  }
}

// 定义一个父类
class Person7{

  var name:String = _
  var age:Int = _

  println("父类调用")

  def this(name:String,age:Int){
    this()
    println("父类的辅助构造器调用")
    this.age = age
    this.name = name
  }

  def pritInfo():Unit = {
    println(s"Person : $name $age")
  }
}

//定义子类
// extends 后面也是 构造器，你也可以 extends Person7(name:String,age:Int)
// 写任意的辅助构造器，反正都会调用主构造器
class Student7(name:String,age:Int) extends Person7{
  var stdNo:String = _

  println(" 子类的柱构造调用")

  def this(name:String,age:Int,stu:String){
    // 继承关系下，会先初始化父类的构造器，再去初始化子类的
    this(name,age)
  }
}
